package text.adventure.input;

import java.util.Map;

import text.adventure.data.TextCommand;


public class SynFilter {
	
	Map<String, String> synonyms;
	
	public SynFilter(Map<String, String> synonyms) {
		this.synonyms = synonyms;
	}
	
	public TextCommand filter(TextCommand in) {
		String verb = in.getVerb();
		if (synonyms.containsKey(verb)) {
			in.setVerb(synonyms.get(verb));
		}
		
		String[] obj = in.getObjects();
		for (int i = 0; i < in.getObjects().length; i++) {
			if (synonyms.containsKey(obj[i])) {
				in.setObject(i, synonyms.get(obj[i]));
			}
		}
		return in;
	}
	
}
